package cn.zooz.admin.config.shiro.tag;

import com.jagregory.shiro.freemarker.ShiroTags;
import freemarker.template.Configuration;
import org.springframework.beans.factory.InitializingBean;

import javax.annotation.Resource;

/**
 * Created by Bradish7Y on 2017/9/9.
 * use shiro tag in freemarker template
 */
public class PlatformFreeMarkerConfigurer implements InitializingBean {

    @Resource
    private Configuration configuration;

    @Override
    public void afterPropertiesSet() throws Exception {
        ShiroTags shiroTags = new ShiroTags();
        shiroTags.put("hasAnyPermissions", new HasAnyPermissionsTag());
        shiroTags.put("hasAllPermissions", new HasAllPermissionsTag());

        configuration.setSharedVariable("shiro", shiroTags);
    }
}